package collection;

import java.util.Deque;
import java.util.LinkedList;

/**
 * java.util.Deque接口 双端队列。Deque接口继承自Queue接口。双端队列的特点是
 * 队列两端都可以进行出入队操作。
 * 实现类:java.util.LinkedList
 * @author 范传奇
 *
 */
public class DequeDemo {
	public static void main(String[] args) {
		Deque<String> deque = new LinkedList<>();
		deque.offer("one");
		deque.offer("two");
		deque.offer("three");
		System.out.println(deque);
		//从队首入队
		deque.offerFirst("four");
		System.out.println(deque);
		//从队尾入队，与offer一致
		deque.offerLast("five");
		System.out.println(deque);
		
		
		String str = deque.poll();
		System.out.println(str);
		System.out.println(deque);
		
		str = deque.pollLast();
		System.out.println(str);
		System.out.println(deque);
		
		str = deque.pollFirst();
		System.out.println(str);
		System.out.println(deque);
		
	}
}









